package com.tanhua.dubbo.api;
import com.tanhua.domain.db.Announcement;
import com.tanhua.domain.vo.PageResult;
import com.tanhua.dubbo.mapper.AnnouncementMapper;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class AnnouncementApiImpl implements AnnouncementApi {
    @Autowired
    private AnnouncementMapper announcementMapper;
    @Override
    public PageResult findAnnouncementList(int page, int pagesize) {
        //items 公告内容
        //id
        //title 标题
        //description 公告内容
        //createDate 发布时间
       page=page-1;
       List<Announcement> list= announcementMapper.findBlackList(page, pagesize);
        //总数量
        int counts = announcementMapper.counts();
        //pagesize
        int pages = (int) Math.ceil(counts* 1.0 / pagesize);
        return new PageResult((int)counts, pagesize, pages, page,list);

        //page

    }
}
